package DensityObjects
{
	import TaskStructure.DensityItem;
	
	import flash.events.Event;
	
	public class FlickableShape extends FlickableMC
	{
		
		public function FlickableShape(type:String, width:Number, height:Number=0, depth:Number=0, _mass:Number=0, _friction:Number=0)
		{
			super(_mass, width * height * depth, _friction);
			width *= DensityItem.CM_TO_PX;
			height *= DensityItem.CM_TO_PX;
			depth *= DensityItem.CM_TO_PX;
			if (type == "RectPrism")
			{
				var dx:Number = width/4;
				var dy:Number = Math.sqrt (depth*depth - dx*dx) /4;
				this.graphics.lineStyle(width/100, 0x444444);
				this.graphics.beginFill (0x00FFFF*_mass);
				this.graphics.drawRect(0, 0, width, height);
				this.graphics.endFill();
				var FROM_LEFT:Boolean = false;
				if (FROM_LEFT)
				{
					this.graphics.beginFill (0x00FFFF*_mass);
					this.graphics.moveTo(0, height);
					this.graphics.lineTo(width, height);
					this.graphics.lineTo(width-dx, height+dy);
					this.graphics.lineTo(-dx, height+dy);
					this.graphics.lineTo(0, height);
					this.graphics.moveTo(0, 0);
					this.graphics.lineTo(-dx, dy);
					this.graphics.lineTo(-dx, dy+height);
					this.graphics.lineTo(0, height);
					this.graphics.lineTo(0, 0);
					this.graphics.endFill();
				} else
				{
					this.graphics.beginFill (0x00FFFF*_mass);
					this.graphics.moveTo(0, height);
					this.graphics.lineTo(width, height);
					this.graphics.lineTo(width+dx, height+dy);
					this.graphics.lineTo(dx, height+dy);
					this.graphics.lineTo(0, height);
					this.graphics.moveTo(width, 0);
					this.graphics.lineTo(width+dx, dy);
					this.graphics.lineTo(width+dx, dy+height);
					this.graphics.lineTo(width, height);
					this.graphics.lineTo(width, 0);
					this.graphics.endFill();
				}
			}
			this.addEventListener(Event.ADDED, handleAdded);
		}
		private function handleAdded (event:Event):void
		{
			this.removeEventListener(Event.ADDED, handleAdded);
			
		}
	}
}